import 'package:enjoy_plus/utils/toast.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class HomeList extends StatelessWidget {
  HomeList({super.key});

  List notifyList = [
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
    {
      'title': '中秋、国庆温馨提示中秋、国庆温馨提示',
      'content': '中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示中秋、国庆温馨提示',
      'createdAt': '2024-09-22 15:00:00',
    },
  ];

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        //  标题
        Row(
          children: [
            Image.asset('images/notice@2x.png', width: 20),
            SizedBox(width: 5),
            Text(
              '社区',
              style: TextStyle(
                color: Colors.black,
                fontSize: 20,
                fontWeight: FontWeight.w700,
              ),
            ),
            Text(
              '公告',
              style: TextStyle(
                color: Colors.orange,
                fontSize: 20,
                fontWeight: FontWeight.w700,
              ),
            ),
          ],
        ),

        //  列表
        ListView(
          shrinkWrap: true, //解决列表嵌套不渲染问题
          physics: NeverScrollableScrollPhysics(), //禁止滚动
          children:
              notifyList.map((item) {
                return GestureDetector(
                  onTap: () {
                    Navigator.pushNamed(
                      context,
                      '/detail',
                      arguments: item['title'],
                    );
                    ToastUtil.showSuccess('成功点击了事件');
                  },
                  child: Container(
                    padding: EdgeInsets.all(10),
                    margin: EdgeInsets.only(top: 10),
                    decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(10),
                    ),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text(
                          item['title'],
                          style: TextStyle(fontWeight: FontWeight.w700),
                        ),
                        SizedBox(height: 10),
                        Text(item['content']),
                        SizedBox(height: 10),
                        Text(
                          item['createdAt'],
                          style: TextStyle(color: Colors.grey),
                        ),
                      ],
                    ),
                  ),
                );
              }).toList(),
        ),
      ],
    );
  }
}
